<extend name="Layout:base"/>

<block name="title">比赛报名系统</block>

<block name="css"></block>

<block name="main">
    <div class="container">
        <div class="section" id="mysec">
            <div class="row">
                <br>
                <form class="col s12" id="from" method="post" action="">
                    <div class="row" id="form">
                        <div class="row">
                            <div class="input-field col s12">
                                <input style="font-size: 30px" type="text" id="enid" class="validate" value="蓝桥杯"
                                       disabled>
                                <input name="enid" type="hidden" value="{$_GET['enid']}">
                                <label class="active" for="enid">你们所参加的比赛:</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12 l6 m6">
                                <input id="stuid" name="stuid" type="text">
                                <label for="stuid">队长-学号：</label>
                            </div>
                            <div class="input-field col s12 l6 m6">
                                <input id="name" name="name" type="text">
                                <label for="name">队长-姓名：</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12 l6 m6">
                                <input id="stuid1" name="stuid1" type="text">
                                <label for="stuid1">成员1-学号：</label>

                            </div>
                            <div class="input-field col s12 l6 m6">
                                <input id="name1" name="name1" type="text">

                                <label for="name1">成员1-姓名：</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12 l6 m6">
                                <input id="stuid2" name="stuid2" type="text">
                                <label for="stuid2">成员2-学号：</label>
                            </div>
                            <div class="input-field col s12 l6 m6">
                                <input id="name2" name="name2" type="text">
                                <label for="name2">成员2-姓名：</label>
                            </div>
                        </div>
                        <div class="row" id="hd3" hidden>
                            <div class="input-field col s12 l6 m6">
                                <input id="stuid3" name="stuid3" type="text">
                                <label for="stuid3">成员3-学号：</label>
                            </div>
                            <div class="input-field col s12 l6 m6">
                                <input id="name3" name="name3" type="text">
                                <label for="name3">成员3-姓名：</label>
                            </div>
                        </div>
                        <div class="row" id="hd4" hidden>

                            <div class="input-field col s12 l6 m6">

                                <input id="stuid4" name="stuid4" type="text">
                                <label for="stuid4">成员4-学号：</label>

                            </div>
                            <div class="input-field col s12 l6 m6">
                                <input id="name4" name="name4" type="text">
                                <label for="name4">成员4-姓名：</label>
                            </div>
                        </div>
                    </div>

                    <a id="addin" class="btn waves-effect waves-light blue" type="#" name="action">添加一个队员</a>

                    <div class="clearfix"></div>
                    <br>
                    <br>
                    <div class="row center">
                        <input class="waves-effect waves-light btn green" type="submit" value="提交报名">
                        &nbsp;
                        <input class="waves-effect waves-light btn grey" type="reset" value="重新填写">
                    </div>
                </form>
            </div>
        </div>
    </div>


</block>

<block name="js">
    <script>
        $(document).ready(function () {

            $i = 3;

            $("#addin").click(function () {
                if ($i < 5) {
                    $("#hd" + $i).show();
                    $i++;
                } else {
                    Materialize.toast('一个团队最多能组5人!', 4000)
                }
            });

            var url = "{:U('Home/Stuform/checkStu')}";

            $("#name").focusout(function () {
                var name = $("#name").val();
                var stuid = $("#stuid").val();
                $.post(url, {name: name, stuid: stuid,}, function (data) {
                    if (data) {
                        $("#a").remove();
                    } else {
                        $("#a").remove();
                        $("#name").after('<span id="a" class="red-text act">学号和姓名不对应</span>');
                    }
                });
            });

            $("#name1").focusout(function () {
                var name = $("#name1").val();
                var stuid = $("#stuid1").val();
                $.post(url, {name: name, stuid: stuid,}, function (data) {
                    if (data) {
                        $("#a1").remove();
                    } else {
                        $("#a1").remove();
                        $("#name1").after('<span id="a1" class="red-text">学号和姓名不对应</span>');
                    }
                });
            });

            $("#name2").focusout(function () {
                var name = $("#name2").val();
                var stuid = $("#stuid2").val();
                $.post(url, {name: name, stuid: stuid,}, function (data) {
                    if (data) {
                        $("#a2").remove();
                    } else {
                        $("#a2").remove();
                        $("#name2").after('<span id="a2" class="red-text act">学号和姓名不对应</span>');
                    }
                });
            });

            $("#name3").focusout(function () {
                var name = $("#name3").val();
                var stuid = $("#stuid3").val();
                $.post(url, {name: name, stuid: stuid,}, function (data) {
                    if (data) {
                        $("#a3").remove();
                    } else {
                        $("#a3").remove();
                        $("#name3").after('<span id="#a3" class="red-text act">学号和姓名不对应</span>');
                    }
                });
            });

            $("#name4").focusout(function () {
                var name = $("#name4").val();
                var stuid = $("#stuid4").val();
                $.post(url, {name: name, stuid: stuid,}, function (data) {
                    if (data) {
                        $("#a4").remove();
                    } else {
                        $("#a4").remove();
                        $("#name4").after('<span id="a4" class="red-text act">学号和姓名不对应</span>');
                    }
                });
            });

        });


    </script>
</block>